package com.me.screen;

import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.me.constant.Constant;
import com.me.info.PlayBoardInfo;
import com.me.ui.HeaderGame;
import com.me.utils.ProcessData;

public class PlayScreen extends BaseScreen {

	private PlayBoardInfo playBoardInfo;
	
	@Override
	public void show() {
		super.show();
		
		stage.clear();
		
		createPlayBoard();
		Constant.clickSound = Gdx.audio.newSound(Gdx.files.internal("music/click.wav"));
		Constant.matchMusic = Gdx.audio.newMusic(Gdx.files.internal("music/match.mp3"));
		stage.setViewport(1280, 720, false);
	}

	void createPlayBoard(){
		resetStartGame();
		Constant.getPicAndWidthLevel();
		ArrayList<Integer> listRand = new ArrayList<Integer>();
		ProcessData.RandomNumber(listRand, Constant.numCouplePics); // Danh sách ngẫu nhiên
		
		playBoardInfo = new PlayBoardInfo(ProcessData.getImage(listRand), Constant.row, Constant.col, Constant.wh_Image);
		HeaderGame header = new HeaderGame("KID MEMO QUIZ", Constant.STAGE_WIDTH, Constant.STAGE_HEIGHT, 1);
		
		stage.addActor(header);
		stage.addActor(playBoardInfo);
	}
	
	void resetStartGame(){
		PlayBoardInfo.iCountEqual = 0;
		PlayBoardInfo.iClick = 0;
	}
	
	@Override
	public void render(float arg0) {
		Gdx.gl.glClearColor(0, 0, 0.2f, 1);
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

		// tell the camera to update its matrices.
		camera.update();

		// tell the SpriteBatch to render in the coordinate system specified by the camera.
		sb.setProjectionMatrix(camera.combined);

		// begin a new batch and draw the bucket and all drops
		sb.begin();
		sb.end();
		stage.setViewport(Constant.STAGE_WIDTH, Constant.STAGE_HEIGHT,false);
	}	
}
